﻿using System;
using YhmOA.Model;
using System.Web.UI.WebControls;
using YhmOA.IDAL;
using YhmOA.Common;

namespace YhmOA.ManagerOA.Menu
{
    public partial class TopMenuList : ManagerPage<ManagerOA_Menu_TopMenu>
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        #region GridView的行绑定事件
        protected void gvShow_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                ManagerOA_Menu_TopMenu info = e.Row.DataItem as ManagerOA_Menu_TopMenu;
                ImageButton ImgBtnBefore = e.Row.FindControl("ImgBtnBefore") as ImageButton;
                ImageButton ImgBtnAfter = e.Row.FindControl("ImgBtnAfter") as ImageButton;
                if (ImgBtnBefore != null)
                {
                    ImgBtnBefore.CommandArgument = info.ID.ToString();
                    ImgBtnBefore.OnClientClick = ImgBtnBefore.OnClientClick + "; __doPostBack('" + ImgBtnBefore.UniqueID + "', '');return false;";
                }
                if (ImgBtnAfter != null)
                {
                    ImgBtnAfter.CommandArgument = info.ID.ToString();
                    ImgBtnAfter.OnClientClick = ImgBtnAfter.OnClientClick + "; __doPostBack('" + ImgBtnAfter.UniqueID + "', '');return false;";
                }
            }
        }
        #endregion

        #region GridView的行内事件
        protected void gvShow_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "ImgBtnBefore")
            {
                DataProvider.GetEFDal<IManagerOA_Menu_TopMenuDAL>().TopMenuOrder(Convert.ToInt32(e.CommandArgument), 1);
                this.Search();
            }
            if (e.CommandName == "ImgBtnAfter")
            {
                DataProvider.GetEFDal<IManagerOA_Menu_TopMenuDAL>().TopMenuOrder(Convert.ToInt32(e.CommandArgument), 0);
                this.Search();
            }
        }
        #endregion
    }
}